package org.noote.libs.voxel;

import org.noote.libs.sogle.Vector3D;

public class Sprite3D {

	private int _len_x = 0;
	private int _len_y = 0;
	private int _len_z = 0;
	byte [][][] _datas = null;
	
	Vector3D translation = new Vector3D(0, 0, 0);
	float scale = 1.0f; 
	float red=1, green=1, blue=1, alpha=1;
	
	public boolean createVolume(int x, int y, int z)
	{
		return createVolume(x, y, z, (byte)-127);
	}
	
	public boolean createVolume(int x, int y, int z, byte val)
	{
		if(x<2 || y<2 || z<2)
			return false;
		
		_datas = new byte[x][y][z];
		if(_datas == null)
			return false;

		setSizeX(x);
		setSizeY(y);
		setSizeZ(z);
		fill(val);
		return true;
	}

	public void fill(byte val)
	{
		for(int x=0; x<getSizeX(); x++)
		{
			for(int y=0; y<getSizeY(); y++)
			{
				for(int z=0; z<getSizeZ(); z++)
				{
					_datas[x][y][z] = val;
				}
			}
		}
	}
	
	public boolean setVoxel(int x, int y, int z, byte val)
	{
		if(x>=0 && x<getSizeX() && y>=0 && y<getSizeY() && z>=0 && z<getSizeZ())
		{
			_datas[x][y][z] = val;
			return true;
		}
		
		return false;
	}

	public void setPosition(float x, float y, float z)
	{
		translation.x = x;
		translation.y = y;
		translation.z = z;
	}

	public void setScale(float s)
	{
		scale = s;
	}

	public void setColor(float r, float g, float b) {
		setColor(r, g, b, 1);
	}
	public void setColor(float r, float g, float b, float a) {
		red = r;
		green = g;
		blue = b;
		alpha = a;
	}

	/**
	 * @param _len_x the _len_x to set
	 */
	public void setSizeX(int _len_x) {
		this._len_x = _len_x;
	}

	/**
	 * @return the _len_x
	 */
	public int getSizeX() {
		return _len_x;
	}

	/**
	 * @param _len_y the _len_y to set
	 */
	public void setSizeY(int _len_y) {
		this._len_y = _len_y;
	}

	/**
	 * @return the _len_y
	 */
	public int getSizeY() {
		return _len_y;
	}

	/**
	 * @param _len_z the _len_z to set
	 */
	public void setSizeZ(int _len_z) {
		this._len_z = _len_z;
	}

	/**
	 * @return the _len_z
	 */
	public int getSizeZ() {
		return _len_z;
	}
}
